<?php

namespace App\Model\Admin;

use App\Model\BaseModel;

/**
 * 字典类型-模型
 * @author LZH
 * @since: 2021/08/12
 * Class DictTypeModel

 */
class DictTypeModel extends BaseModel
{
    // 设置数据表名
    protected $tableName = DB_PREFIX . "dict_type";

    /**
     * 获取缓存信息
     * @param int $id 记录ID
     * @author LZH
     * @since: 2021/08/12
     */
    public function getInfoById($id, $append = [], $visible=[], $hidden = [])
    {
        $info = parent::getInfoById($id);
        if ($info) {
        }
        return $info;
    }

    public function getDictionaryByDictType(string $DictTypeCode)
    {
        $dictTypeTable = $this->tableName;
        $dictionaryTable = DB_PREFIX . 'dictionary';
        $result = $this->join($dictionaryTable, "$dictTypeTable.id = $dictionaryTable.dict_type_id")->where("$dictTypeTable.code", $DictTypeCode)
            ->field(["$dictionaryTable.code as code", "$dictionaryTable.name as name"])
            ->all()->toArray();
        return $result;
    }
}
